import { fileURLToPath, URL } from 'node:url'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'
// https://vitejs.dev/config/

export default defineConfig({
  plugins: [
    // 解析单文件组件的插件
    vue({
      //开启解构Props响应式转换功能
      reactivityTransform: true
    }),
    // 自动导入的插件，解析器可以是 vant element and-vue 
    Components({
      dts: false,
      // 原因：Toast Confirm 这类组件的样式还是需要单独引入，样式全局引入了，关闭自动引入
      resolvers: [VantResolver({ importStyle: false })]
    }),
    createSvgIconsPlugin({
      // Specify the icon folder to be cached
     iconDirs: [path.resolve(process.cwd(), "src/icons")],
     symbolId: "icon-[dir]-[name]",
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    port: 8088,
    host:true,
    
  }
})
